package uk.ac.aber.paws.server.util;

import uk.ac.aber.paws.server.net.SendMessage;

/**
 * @author Rob Johnson, Aberystwyth University
 * @email rob.johnson@aber.ac.uk
 * @date 16th August 2011
 * 
 * CallQueueDebug.java
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

public class CallQueueDebug {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		if (args.length != 2) {
			System.out.println("Usage: java -classpath pawsserver.jar uk.ac.aber.paws.server.util.CallQueueDebug <refresh secs> <port>");
			System.exit(1);
		}
		while (true) {
			
			try {
				System.out.println("Current Logins:");
				
				int queueLength = SendMessage.requestCallDBLength(Integer.parseInt(args[1]));		
		
				System.out.println("Queue Length="+queueLength);
				
				Thread.currentThread().sleep(Integer.parseInt(args[0])*1000);
				
			} catch (NumberFormatException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
